<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>排序</title>
</head>
<body>
    <script>
        let arr=[5,4,3,2,1];
       /* arr.sort(function(n1,n2){
            return n1-n2;
        });*/
        //arr.sort((n1,n2)=>{return n1-n2;});
        arr.sort((n1,n2)=>n1-n2);

        alert(arr);
    </script>
</body>
</html>